package com.twu.biblioteca.service;

import com.twu.biblioteca.model.user;

/**
 * Created with IntelliJ IDEA.
 * User: st
 * Date: 14-4-23
 * Time: 下午3:55
 * To change this template use File | Settings | File Templates.
 */
public class setupUsers {
    public static user setUser(user userList,String name,String password,String email,String phoneNumber,String identity)
    {   userList = new user();
        userList.setCustomerName(name);
        userList.setPassword(password);
        userList.setEmail(email);
        userList.setPhoneNumber(phoneNumber);
        userList.setIdentity(identity);
        return userList;
    }

    public user[] setUsers(user[] userList){
        userList[0]=setUser(userList[0],"Tom","ttt","Tom@gmail.com","88726162","customer");
        userList[1]=setUser(userList[1],"Marry","mmm","Marry@gmail.com","82636162","customer");
        userList[2]=setUser(userList[2],"Lily","lll","Lily@gmail.com","56786162","librarian");
        return userList;
    }


    public static void printUserList(user userList1[], int len){

        int len1=0;
        System.out.println("User name"+"\t"+"   email"+"\t"+"phone number");

            if(userList1[len].getIdentity().equals("customer")){
                System.out.println(userList1[len].getCustomerName()+"        \t"+userList1[len].getEmail()+"       \t"+userList1[len].getPhoneNumber()+"      \t"+userList1[len1].getBook());
            }
                if(!userList1[len].getIdentity().equals("customer")){
                    while (len1<userList1.length&&userList1[len1]!=null){
                        System.out.println(userList1[len1].getCustomerName()+"        \t"+userList1[len1].getEmail()+"       \t"+userList1[len1].getPhoneNumber()+"      \t"+userList1[len1].getBook());
                        len1++;
                    }
            }


    }
}
